package cz.cvut.vrtisja2.muchktom;
import cz.cvut.vrtisja2.muchktom.dialogs.AddListDialog;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

public class HomeActivity extends Activity {
	
	/*------------------------------------------ properties ------------------------------------------*/
	private View addList = null;
	private View lists = null;
	private View settings = null;
	private View sync = null;
	private View lastList = null;
	
	
	/*------------------------------------------ methods ------------------------------------------*/
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.main);
		init();
		
	}
	
	@Override
	protected Dialog onCreateDialog(int id) {
		return super.onCreateDialog(id);
	}
	
	private void init() {
		
		addList = findViewById(R.id.main_add_icon);
		lists = findViewById(R.id.main_list_icon);
		settings = findViewById(R.id.main_settings_icon);
		sync = findViewById(R.id.main_sync_icon);
		lastList = findViewById(R.id.main_lastListButton);
		
		/*lists.setOnClickListener(this.listsListener);
		settings.setOnClickListener(this.settingsListener);
		sync.setOnClickListener(this.syncListener);
		lastList.setOnClickListener(this.lastListListener);
		addList.setOnClickListener(this.addListener);*/
	}
	
	private void createAddDialog() {
		Dialog dialog = new AddListDialog(HomeActivity.this);
        dialog.show();
	}
	
	private OnClickListener addListener = new OnClickListener() {

		@Override
		public void onClick(View arg0) {
			createAddDialog();
			
		}
		
	};
	
	private OnClickListener listsListener = new OnClickListener() {

		@Override
		public void onClick(View arg0) {
			Context ctx = HomeActivity.this;
			Intent i = new Intent(ctx, ListsActivity.class);
			startActivity(i);
			
		}
		
	};
	
	private OnClickListener settingsListener = new OnClickListener() {

		@Override
		public void onClick(View arg0) {
			Context ctx = HomeActivity.this;
			Intent i = new Intent(ctx, SettingsActivity.class);
			startActivity(i);
			
		}
		
	};
	
	private OnClickListener syncListener = new OnClickListener() {

		@Override
		public void onClick(View arg0) {
			/*LayoutInflater inflater = getLayoutInflater();
			View layout = inflater.inflate(R.layout.toast_sync, (ViewGroup) findViewById(R.id.toast_sync_root));
			
			Toast toast = new Toast(getApplicationContext());
			toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
			toast.setDuration(Toast.LENGTH_LONG);
			toast.setView(layout);
			toast.show();*/
			
			Toast toast = Toast.makeText(HomeActivity.this, R.string.toast_text, Toast.LENGTH_LONG);
			toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
			toast.show();
		}
		
	};
	
	private OnClickListener lastListListener = new OnClickListener() {

		@Override
		public void onClick(View arg0) {
			Context ctx = HomeActivity.this;
			Intent i = new Intent(ctx, List.class);
			startActivity(i);
			
		}
		
	};

}
